package com.zephyr.vchcenter.bpm.action;

import org.apache.log4j.Logger;

import com.hiaward.bpm.action.TaskAction;
import com.hiaward.bpm.context.ServiceContext;
import com.hiaward.bpm.exception.ParameterException;
import com.hiaward.bpm.exception.ServiceException;
import com.zephyr.vchcenter.bean.Voucher;
import com.zephyr.vchcenter.dao.IBaseDao;
import com.zephyr.vchcenter.helper.SpringHelper;

public class TallyFailedAuditAction extends TaskAction{

	private static Logger log = Logger.getLogger(TallyFailedAuditAction.class);
	@Override
	public void perform(ServiceContext sc) throws ServiceException,
			ParameterException {
		log.debug("����TallyFailedAuditAction进入TallyFailedAuditAction..............");
		String vchsid=(String)sc.getInputParameterValue("vchsid");
		log.debug(vchsid);
		/*String accno = (String) sc.getInputParameterValue("accno");
		String vchno = (String) sc.getInputParameterValue("vchno");
		String amount = (String) sc.getInputParameterValue("amount");
		String subno = (String) sc.getInputParameterValue("subno");
		String brbank = (String) sc.getInputParameterValue("brbank");
		String vsbank = (String) sc.getInputParameterValue("vsbank");*/
		String result = (String) sc.getInputParameterValue("restally");
		String rtreason=(String)sc.getInputParameterValue("rtreason");
		String rereason=(String)sc.getInputParameterValue("rereason");
		IBaseDao dao=(IBaseDao)SpringHelper.getBean("baseDao");
        Voucher voucher=(Voucher)dao.findById("Voucher", vchsid);
        /*voucher.setAccno(accno);
		voucher.setVchno(vchno);
		voucher.setAccno(accno);
        voucher.setAmount(amount);
        voucher.setSubno(subno);
        voucher.setBrbank(brbank);
        voucher.setVsbank(vsbank);*/
        voucher.setRestally(result);
        voucher.setRtreason(rtreason);
        voucher.setRereason(rereason);
        //voucher.setRestally(3);
        
//		sc.setOutputParameterValue("accno", accno);
//		sc.setOutputParameterValue("vchno", vchno);
//		sc.setOutputParameterValue("amount", amount);
//		sc.setOutputParameterValue("result", Integer.parseInt(result));
		if ("0".equals(result)) {
			log.debug("记帐");
			voucher.setTallytype("1");
		}else if("1".equals(result)){
			//voucher.setTallytype(3);
			log.debug("退票");
			voucher.setTallytype("2");
		}
		dao.saveOrUpdate(voucher);
		log.debug("离开TallyFailedAuditAction...............");
	}

	@Override
	public void serviceExceptionHandle(ServiceContext arg0,
			ServiceException arg1) {
	}

}
